package main

import (
	"net/http"
	_ "go-web/service"
	_ "go-web/router"
	"go-web/router"
	"time"
	"os"
	"go-web/service"
)

func main()  {
	//多路复用器
	mux := http.NewServeMux()

	router := &router.Router{mux}
	router.HandleRouter()

	server := &http.Server{
		Addr: service.Get("app.server.port"),
		ReadTimeout:time.Duration(service.GetInt64Def("app.server.readtimeout", 50)) * time.Millisecond,
		WriteTimeout:time.Duration(service.GetInt64Def("app.server.writetimeout", 500)) * time.Millisecond,
		Handler:mux,
	}
	//定义并启动服务
	err := server.ListenAndServe();
	if err != nil {
		os.Exit(-1)
	}
}
